<template>
  <transition name="fade">
    <div class="message" :class="type" v-if="visible">
      <i class="icon-type iconfont" :class="'icon-'+type"></i>
      <div class="content">
        {{content}}
        <i v-if="hasClose" class="btn-close iconfont icon-close" @click="visible=false"></i>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: "Tips",
  data() {
    return {
      content: "",
      time: 2000,
      visible: false,
      type: "info", //'success','warning','error'
      hasClose: false
    };
  },
  mounted() {
    this.close();
  },
  methods: {
    close() {
      window.setTimeout(() => {
        this.visible = false;
      }, this.time);
    }
  }
};
</script>
<style>
.message {
  font-size: 16px;
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 99999;
  padding: 15px 30px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 30px;
  color: #fff;
  transform: translate(-50%, -50%);
}
</style>
